#!/bin/bash

#filepath=$1
#
##删除历史数据
#rm -rf $1

appname=$1
#apptype=$2
#获取传入参数
echo "arg_appname: $1"
#echo "arg_apptype: $2"

#获取正在运行的jar包pid
#pid=`ps -ef | grep $1 | grep $apptype | grep -v grep | awk 'NR==1 {print $2}'`
pid=`ps -ef | grep $1 | grep -v grep | awk 'NR==1 {print $2}'`
echo "pid: $pid"

#如果pid为空，提示一下，否则，执行kill命令
if [ -z $pid ];
#使用-z 做空值判断
	then
		echo "$appname not started"

	else
		kill -9 $pid
		echo "$appname stoping...."

fi

#check=`ps -ef | grep -w $pid | grep $2 | grep -v grep | awk 'NR==1 {print $2}'`
check=`ps -ef | grep -w $pid | grep -v grep | awk 'NR==1 {print $2}'`
echo "check: $check"

if [ -z $check ];

	then
		echo "$appname pid:$pid is stop"

	else
		kill -15 $pid
		echo "$appname stop failed"

fi

